{% set pypi_name = 'os-client-config' %}
{% set upstream_version = upstream_version('2.1.0') %}
{% set rpm_release = '1' %}
{% set source = url_pypi() %}
%global sname os-client-config
%bcond_with test
%bcond_with docs
Name:           {{ py2name() }}
Version:        {{ py2rpmversion() }}
Release:        {{ py2rpmrelease() }}
Summary:        OpenStack Client Configuration Library
License:        {{ license('Apache-2.0') }}
Group:          Development/Languages/Python
URL:            https://docs.openstack.org/{{ pypi_name }}
Source0:        {{ source }}
BuildRequires:  openstack-macros
BuildRequires:  {{ py3('pbr') }}
BuildArch:      noarch
%if %{with test}
BuildRequires:  {{ py3('extras') }}
BuildRequires:  {{ py3('fixtures') }}
BuildRequires:  {{ py3('python-glanceclient') }}
BuildRequires:  {{ py3('jsonschema') }}
BuildRequires:  {{ py3('python-keystoneclient') }}
BuildRequires:  {{ py3('mock') }}
BuildRequires:  {{ py3('oslotest') }}
BuildRequires:  {{ py3('python-subunit') }}
BuildRequires:  {{ py3('stestr') }}
BuildRequires:  {{ py3('testscenarios') }}
BuildRequires:  {{ py3('testtools') }}
%endif

%description
os-client-config is a library for collecting client configuration for
using an OpenStack cloud in a consistent and comprehensive manner.
It will find cloud config for as few as 1 cloud and as many as you want
to put in a config file. It will read environment variables and config
files, and it also contains some vendor specific default values so that
you don't have to know extra info to use OpenStack.

%package -n {{ py2name(py_versions='py3') }}
Summary:        OpenStack Client Configuration Library
Requires:       {{ py3('PyYAML') }}
Requires:       {{ py3('appdirs') }}
Requires:       {{ py3('keystoneauth1') }}
Requires:       {{ py3('requestsexceptions') }}

%description -n {{ py2name(py_versions='py3') }}
os-client-config is a library for collecting client configuration for
using an OpenStack cloud in a consistent and comprehensive manner.
It will find cloud config for as few as 1 cloud and as many as you want
to put in a config file. It will read environment variables and config
files, and it also contains some vendor specific default values so that
you don't have to know extra info to use OpenStack.

This package contains the Python 3.x module.

%if %{with docs}
%package -n python-os-client-config-doc
Summary:        Documentation for OpenStack client configuration library
BuildRequires:  {{ py3('Sphinx') }}
BuildRequires:  {{ py3('openstackdocstheme') }}
BuildRequires:  {{ py3('reno') }}

%description -n python-os-client-config-doc
Documentation for the os-client-config library.
%endif

%prep
%autosetup -p1 -n %{sname}-%{version}
%py_req_cleanup

%build
%py3_build
%if %{with docs}
# generate html docs
PBR_VERSION=%{version} %sphinx_build -b html doc/source doc/build/html
# remove the sphinx-build leftovers
rm -rf doc/build/html/.{doctrees,buildinfo}
%endif

%install
%py3_install

%if %{with test}
%check
export PYTHONPATH="%{python3_sitearch}:%{python3_sitelib}:%{buildroot}%{python3_sitelib}"
python3 -m stestr.cli run
%endif

%files -n {{ py2name(py_versions='py3') }}
%license LICENSE
%doc README.rst
%{python3_sitelib}/os_client_config
%{python3_sitelib}/*.egg-info

%if %{with docs}
%files -n python-os-client-config-doc
%doc doc/build/html
%license LICENSE
%endif

%changelog
